package com.yj.web;

import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import com.yj.entity.Comments;
import com.yj.service.ICommentsService;
import com.yj.vo.JsonResult;

import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author yj
 * @since 2020-08-24
 */
@RestController
//@RequestMapping("/comments")
public class CommentsController {
	
	@Autowired
	ICommentsService commentsService;
	
	//查询该房源下的评论
	@PostMapping("/showComments")
	public JsonResult showComments(int hid ) {
		return commentsService.showComments(hid);
	}
	
	//删除登录用户自己的评论
	@PostMapping("/users/delComments")
	public JsonResult delComments(int pid,HttpSession session ) {
		return commentsService.delComments(pid, session);
	}
	
	//添加评论
	@PostMapping("/users/addComments")
	public JsonResult addComments(Comments comments,HttpSession session ) {
		return commentsService.addComments(comments, session);
	}
	
	
	
	
	
	

}
